package org.jeecg.modules.aliyun.entity.run;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.modules.phone.entity.PhoneEntity;
import org.jeecg.modules.phone.entity.PhoneEntityTask;
import org.jeecg.modules.phone.entity.PhoneEntityTaskRsource;
import org.jeecg.modules.phone.mapper.PhoneAccountLogMapper;
import org.jeecg.modules.phone.mapper.PhoneEntityCmdMapper;
import org.jeecg.modules.phone.mapper.PhoneEntityTaskRsourceMapper;
import org.jeecg.modules.system.util.HttpDownloadUtil;
import org.springframework.beans.factory.annotation.Autowired;

import static org.jeecg.modules.aliyun.entity.run.TaskUtil.cmdBy4G;
import static org.jeecg.modules.aliyun.entity.run.TaskUtil.sleepSecond;

public class PhoneEntityTaskZ2Util {
    @Autowired
    PhoneEntityTask phoneEntityTask;
    @Autowired
    PhoneEntity phoneEntity;
    @Autowired
    PhoneAccountLogMapper phoneAccountLogMapper;
    @Autowired
    PhoneEntityCmdMapper phoneEntityCmdMapper;





    public static void asdfa461(PhoneEntityTask phoneEntityTask) {

        cmdBy4G(phoneEntityTask,"am force-stop com.ss.android.ugc.aweme");
        sleepSecond(5);
        cmdBy4G(phoneEntityTask,"am start com.ss.android.ugc.aweme/.main.MainActivity");
        sleepSecond(50);
        cmdBy4G(phoneEntityTask,"input tap 306 1667"); //点等待306 1667
        cmdBy4G(phoneEntityTask,"input tap 108 1727"); //点首页108 1727
        cmdBy4G(phoneEntityTask,"input tap 1009 162");
        cmdBy4G(phoneEntityTask,"ime set com.android.adbkeyboard/.AdbIME");
        cmdBy4G(phoneEntityTask,"input tap 428 165");
        cmdBy4G(phoneEntityTask,"am broadcast -a ADB_INPUT_TEXT --es msg '花海图册小程序'");
        cmdBy4G(phoneEntityTask,"input tap  982 139"); //点搜索982 139
        //检查是否有对比图，如果没有就继续。如果有就停了。
        TaskUtil.checkPointJob(phoneEntityTask,"a4",0  );

    }


    public static void asdfa462(PhoneEntityTask phoneEntityTask) {

        cmdBy4G(phoneEntityTask,"input tap  910 555"); //点进入910 555
        sleepSecond(135,"进入小程序");
        cmdBy4G(phoneEntityTask,"input tap  244 727"); //点口令342 807  //点口令244 727
        cmdBy4G(phoneEntityTask,"input tap  244 727"); //点口令342 807  //点口令244 727


        PhoneEntityTaskRsourceMapper phoneEntityTaskRsourceMapper = SpringContextUtil.getBean(PhoneEntityTaskRsourceMapper.class);
        PhoneEntityTaskRsource phoneEntityTaskRsource
                =  phoneEntityTaskRsourceMapper.selectOne(
                new QueryWrapper<PhoneEntityTaskRsource>().lambda()
                        .eq(PhoneEntityTaskRsource::getEntityId,phoneEntityTask.getEntityId())
                        .eq(PhoneEntityTaskRsource::getTaskId,"a4").last("limit 1")
        );
        String code = HttpDownloadUtil.readRemoteTxt(phoneEntityTaskRsource.getTxt().toString());
        cmdBy4G(phoneEntityTask,"input text " + code );
        cmdBy4G(phoneEntityTask,"input tap  941 729");//点搜索口令945 797  //点搜索口令941 729
        sleepSecond(10,"进入小程序");
        cmdBy4G(phoneEntityTask,"input tap  169 938"); //第一作品 169 938
        sleepSecond(10,"进入第一个作品");

        cmdBy4G(phoneEntityTask,"input tap  957 1204"); //点下载957 1204
        cmdBy4G(phoneEntityTask,"input tap  340 1190"); //点保存高清 340 1190

        sleepSecond(60,"看广告");
        cmdBy4G(phoneEntityTask,"input tap  975 102");  //关闭 975 102
        sleepSecond(60,"下载完成");
        cmdBy4G(phoneEntityTask,"am force-stop com.ss.android.ugc.aweme");


        //检查是否有对比图，如果没有就继续。如果有就停了。
        TaskUtil.checkPointJob(phoneEntityTask,"a4",1  );
    }

}